package xyz.shenmegui.foodcheckserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xyz.shenmegui.foodcheckserver.DO.DailyRecommend;
import xyz.shenmegui.foodcheckserver.DO.Menu;
import xyz.shenmegui.foodcheckserver.mapper.MenuMapper;
import xyz.shenmegui.foodcheckserver.service.MenuService;
import xyz.shenmegui.foodcheckserver.utils.DateUtils;

import java.time.LocalDate;
import java.util.List;

@Service
@Transactional
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public Menu getMenuById(Integer id) {
        return menuMapper.selectById(id);
    }

    @Override
    public List<Menu> getMenuBySeedId(Integer id) {
        LambdaQueryWrapper<Menu> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Menu::getSeed, id);
        return menuMapper.selectList(queryWrapper);
    }

    @Override
    public void insertMenus(List<Menu> menus) {
        for (Menu menu : menus) {
            if (menu != null) {
                menuMapper.insert(menu);
            }
        }
    }
}
